home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 28
/
Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso
/
Aminet
/
dev
/
amos
/
intuiextend16.lha
/
bonus
/
easylife
/
demos
/
Shorten.AMOS
/
Shorten.amosSourceCode
Wrap
AMOS Source Code
|
1992-02-26
|
6KB
|
158 lines
'****************************************************************************
'** Program Shortener V1.0 - By Paul Hickman (ph@doc.ic.ac.uk) **
'** **
'** Requires AMOS Pro & Easylife V1.4+ Distributed as an Eastlife Demo **
'** **
'** Do not use this accessory on programs which contain procedures that **
'** not be unfolded, if they have variable names in the parameters of 2 **
'** characters or more! **
'****************************************************************************
Set Accessory
Set Buffer 50
Dim TB$(30)
Global AL$,WHITE$,TB$(),NNAME,QUOTE$
For A=0 To 30 : TB$(A)="|" : Next
WHITE$=Chr$(32)+Chr$(9) : SCY=60 : NNAME=0 : FOLD$="" : LABEL$="|"
QUOTE$=Chr$(34)+Chr$(39)
NAST$=QUOTE$+"ABCDEFGHIJKLMNOPQSTRUVWXYZ_"
INIT_SCREEN
' Make sure we are an accessory
If Prg Under<>1
If Exist("Shorten.Doc")
Read Text "Shorten.Doc"
Else
NULL=Dialog Box(AL$,1,"This program must be run as an accessory!")
End If
MN_QUIT
End If
DLOG2["Shorten Variable Names, Or Just Strip Comments","Comments","Variables"] : SHORT=(Param=2)
If SHORT
SCAN_FOLDED
If Param
DLOG2["Program contains calulcated branches. Labels will not be shortened","Continue","Abort"]
If Param=2 : MN_QUIT : End If
End If
End If
COMMENT_STRIP[SHORT]
MN_QUIT
Procedure SHORTEN
Shared LINE$,NAST$
CHANGE=False
A= Extension_16_00AA(LINE$,NAST$)
While A>0
B=Peek(Varptr(LINE$)+A-1)
If(B=39) or(B=34)
C= Extension_16_009E(LINE$,B,A)
Exit If C=0
A=C
Else
C=Peek(Varptr(LINE$)+A)
If((C>64) and(C<91)) or((C>47) and(C<58)) or(C=95)
'Looks Like A Legal Label - Check Quotes & Hex String
NHEX=True
DL= Extension_16_0122(LINE$,36,A)
If DL>0
NHEX=( Extension_16_00EA(Mid$(LINE$,DL+1,A-DL),"0123456789ABCDEF")>0)
End If
If NHEX
C= Extension_16_0100(LINE$,"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_",A)
If C=0
N$=Mid$(LINE$,A)
Else
N$=Mid$(LINE$,A,C-A)
End If
SHORT_LOOKUP[N$] : L$=Param$
If L$=""
Add A,Len(N$)
Else
LINE$=Left$(LINE$,A-1)+L$+Mid$(LINE$,A+Len(N$))
Add A,Len(L$)
CHANGE=True
End If
End If
Else
'Not a label - check for a zero, -1 or 4
' If(L<250) and(A>0)
' C=Peek(Varptr(LINE$)+A-1)
' If Elf asc(" ,=<>(*+/[",C)>0
' If(B=48) or(B=52)
' C=Peek(Varptr(LINE$)+A+1)
' If((C<48) or(C>57)) and(C<>46)
' QUOTE_CHECK[Left$(LINE$,A+1)]
' If Param=False
' AA$="False" : If B=52 : AA$="Laced" : End If
' LINE$=Left$(LINE$,A)+AA$+Mid$(LINE$,A+2)
' End If
' End If
' End If
' End If
' End If
End If
End If
A= Extension_16_00BC(LINE$,NAST$,A)
Wend
End Proc[CHANGE]
Procedure SHORT_LOOKUP[A$]
Shared LABEL$
X=Asc(A$)-65
If(X<0) or(X>30)
Error 23
End If
NO=Instr(LABEL$,"|"+A$+"|")
If NO
B$=""
Else
A=Instr(TB$(X),"|"+A$+"|")
If A>0
B$=Upper$(Mid$(TB$(X),A+Len(A$)+2,Instr(TB$(X),"|",A+Len(A$)+2)-A-Len(A$)-2))
Else
'1st Character Of Label = letter NNAME mod 25
'2nd Character Of Label = number nname/25 mod 10 (Prevents labels matching instructions like At)
'3rd Character Of Label (if Present) = letter NNAME / 250
'
Repeat
B$=Chr$(NNAME mod 25+65)+Chr$((NNAME/25) mod 10+48)
If NNAME=>250
B$=B$+Chr$(NNAME/250+65)
End If
Inc NNAME
Until Instr(LABEL$,"|"+B$+"|")=0
TB$(X)=TB$(X)+A$+"|"+Lower$(B$)+"|"
End If
End If
End Proc[B$]
Procedure COMMENT_STRIP[SHORT]
Shared LINE$,FOLD$
TITLE
Clear Key : Y=0 : DELD=0
Call Editor 89 : Rem Equ("AEd_UnfoldAll")
Call Editor 17 : Rem Top Of Text
Ask Editor 5 : NLINES=Param : NFOLD=0
Repeat
DELETE=False
Ask Editor 1 : LINE$=Param$
'Search for ' at start of line
B= Extension_16_00EA(LINE$,WHITE$) : A=Asc(Mid$(LINE$,B))
If(A=39) or(B=0)
Call Editor 23 : Rem Delete Line
Dec NLINES : Inc DELD
DELETE=True
Else
'
'Search For: ,_������gtNup^�� Extension_0_FFFF
Extension_0_6704 Extension_0_7402 Extension_0_4E75 Extension_0_705E Extension_0_FE01 Extension_0_F700 Extension_0_0400 Extension_0_2708 Extension_0_206D Extension_0_01E8 Extension_0_2028 Extension_0_00FC Extension_0_661E Extension_0_48E7 Extension_0_00C2 Extension_0_43FA Illegal_Constant_0022 Extension_0_7005 Extension_0_2C78 L�C Extension_0_4E75 Extension_0_FE31 "| Extension_0_0075 Extension_0_FE31 0�'@��R